package com.example.module_home

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.RecyclerView
import com.example.lib_widget.redpacket.RedPacketEnum
import com.example.lib_widget.redpacket.RedPacketEvent
import com.example.lib_widget.redpacket.RedPacketView
import com.example.lib_widget.redpacket.RedPacketWidget
import com.example.lib_widget.redpacket.RedPacketWidget.StateCallback
import org.greenrobot.eventbus.EventBus

class RedPacketViewActivity : AppCompatActivity() {
    private lateinit var red:RedPacketWidget
    private lateinit var rv:RecyclerView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_red_packet_view)
        red = findViewById(R.id.red_widget)
        rv = findViewById(R.id.rv);
        red.setNum(100);
        red.setStateCallback(object :RedPacketWidget.StateCallback {
            override fun completed() {
                Log.d("TAG", "发起网络请求上报金币: ")
            }

        })
        rv.addOnScrollListener(object : RecyclerView.OnScrollListener(){
            override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
                super.onScrolled(recyclerView, dx, dy)
                //faons
            }

            override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
                super.onScrollStateChanged(recyclerView, newState)

            }
        })

    }

//    fun startAni(view: View) {
//        EventBus.getDefault().post(RedPacketEvent(RedPacketEnum.INIT))
//
//    }
//    fun stopAni(view: View) {
//
//    }cd /Users/yaotianxue/Library/Android/sdk/platform-tools
//
//    fun pauseAni(view: View) {
//        EventBus.getDefault().post(RedPacketEvent(RedPacketEnum.PAUSE))
//    }
//    fun resumeAni(view: View) {
//        EventBus.getDefault().post(RedPacketEvent(RedPacketEnum.RESUME))
//
//    }

}